package com.example.webview;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity2 extends AppCompatActivity {
    private WebView webView;

    @SuppressLint("JavascriptInterface")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main2);
        webView = findViewById(R.id.web_view);
        webView.loadUrl("https://m.qfang.com/hefei/tax/result/apartment?taxCity=hefei&taxArea=100&taxPrice=200&taxSaleOnly=ONLY&taxLastDeal=FIVE_YEARS&taxCalculateWay=TOTAL&taxDifprice=&taxBuyFirst=FIRST&fromSource=app");
        webView.setWebViewClient(new WebViewClient());
        webView.setWebChromeClient(new WebChromeClient());


        webView.getSettings().setJavaScriptEnabled(true);
        webView.addJavascriptInterface(this,"android");

    }
    @JavascriptInterface
    public void jstoNativeCallPhone(String number){
        Toast.makeText(this,"拨打电话"+number,Toast.LENGTH_LONG).show();
    }

}